<template>
  <v-layout>
    <template #header>
      <el-select v-model="classItem" placeholder="请选择商品大类">
        <el-option
          v-for="item in classList"
          @click.native="igetSumOrderInfo(item)"
          :key="item.cclass"
          :label="item.cdesc"
          :value="item.cclass"
        />
      </el-select>
      <el-button
                type="primary"
                @click="printbtn"
                >打印</el-button
              >
    </template>
    <v-table
      url="/querySummaryListByCategory"
      :query="tableQuery"
      AnyObject
      ref="tableRef"
    >
      <v-column auto prop="scName" label="学校名称"></v-column>
      <v-column auto prop="goodsClassName" label="商品大类"></v-column>
      <v-column auto prop="price" label="价格"></v-column>
    </v-table>
  </v-layout>
</template>

<script setup lang="ts">
import { useTable } from "@/components/table/useTable";
import { reactive, ref } from "vue";
import type { classData } from "@/api/user/model";
import { useUserStore } from "@/stores/user";
import { queryAllGoodsClass } from "@/api/user";
const { tableRef, getSelectionRows, reload } = useTable();
//查询供应商信息
const { tznUser } = useUserStore();
const tableQuery = reactive({
  goodsClass: "",
  shopId: "",
  vendorid: tznUser.areaId,
});

const classList = ref<classData[]>([]);
const classItem = ref<classData>({
  cdesc: "",
  cclass: "",
  inum: "",
});
//获取大类信息
queryAllGoodsClass().then((data) => {
  classList.value = data;
  classItem.value = data[0];
  tableQuery.goodsClass = data[0].cclass;
  reload();
});

//根据学校选择
const igetSumOrderInfo = (item: any) => {
  classItem.value = item;
  tableQuery.goodsClass = item.cclass;
  reload();
};
const printbtn = ()=>{
  console.log(111);
  
}
</script>
